package com.huaxia.day18;

import javax.swing.*;
import java.awt.*;

public class BorderLayoutTest {
    public static void main(String[] args) {
       // createAll();
        createNoCenter();
    }

    public static void createAll() {
        JFrame frame = new JFrame("布局器");
        frame.setSize(400, 200);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        BorderLayout layout = (BorderLayout) frame.getLayout();
        frame.add(new JButton("左"), BorderLayout.WEST);
        frame.add(new JButton("上"), BorderLayout.NORTH);
        frame.add(new JButton("中"), BorderLayout.CENTER);
        frame.add(new JButton("下"), BorderLayout.SOUTH);
        frame.add(new JButton("右"), BorderLayout.EAST);

    }

    public static void createNoCenter() {
        JFrame frame = new JFrame("布局器");
        frame.setSize(400, 200);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        BorderLayout layout = (BorderLayout) frame.getLayout();
        frame.add(new JButton("左"), BorderLayout.WEST);
        frame.add(new JButton("上"), BorderLayout.NORTH);
//        frame.add(new JButton("中"), BorderLayout.CENTER);
        frame.add(new JButton("下"), BorderLayout.SOUTH);
        frame.add(new JButton("右"), BorderLayout.EAST);
    }
}
